<?php
/**
 * MongoDig
 *
 * @copyright  Copyright (c) 2010 lanyanguang (http://www.lanyg.com)
 * @license    GNU General Public License 2.0
 * @version    $Id$
 */

/** 初始化 */
require_once 'init.php';

//判断topic_id
if(!isset($_GET['id'])){
	header('Location:'.$config['site_url'].'/index.php');
	exit;
}

//页面提交处理
if(isset($_POST['Submit'])){
	$comment = trim($_POST['comment']);
	if(!empty($comment)){
		include_logic('topic');
		topic_update(
		array('_id'=>new MongoId($_GET['id'])),
		array('$push'=>array('comment'=>array(
			'comment'=>$comment,
			'user_id'=>"$_SESSION[user_id]",
			'entry_time'=>time()
		)))
		);
	}
}

$_GLOBAL['page_title'] = 'Read This Topic';

//载入页面
include_template('topic');